Necessary packages included in the project.

library(rvest)
library(sf)
library(dplyr)
library(kableExtra)
library(leaflet)
library(htmlwidgets)
library(htmltools)

Files with .zip extension are extracted into files.

#unzip the contents in './data/turkey_administrativelevels0_1_2.zip' and save unzipped content in './data/turkey_administrativelevels0_1_2'
unzip(zipfile = "./data/zip/turkey_administrativelevels0_1_2.zip", exdir = "./data/turkey_administrativelevels0_1_2")

#unzip the contents in './data/turkey_centeralpoints_1_2.zip' and save unzipped content in './data/turkey_centralpoints_1_2'
unzip(zipfile = "./data/zip/turkey_centeralpoints_1_2.zip", exdir = "./data/turkey_centralpoints_1_2")

Data with sf structure was obtained with the st_read function.

tur_polbnda_adm1_sf= st_read("data/turkey_administrativelevels0_1_2/tur_polbnda_adm1.shp")
tur_pntcntr_adm1_sf = st_read("data/turkey_centralpoints_1_2/tur_pntcntr_adm1.shp")

Here is the first sf data named tur_polbnda_adm1_sf.

tur_polbnda_adm1_sf %>%
  select("İl Adı"=adm1_tr, "Shape Leng" =Shape_Leng, "Shape Area"=Shape_Area,"Geometry"=geometry) %>%
     kbl(caption = "tur_polbnda_adm1_sf", align = "cccc")%>%
        kable_styling(bootstrap_options = c("striped",
                                            "hover",
                                            "condensed",
                                            "responsive"), 
                      font_size = 12) %>%
          scroll_box(width = "500px", height = "250px") 
tur_polbnda_adm1_sf
İl Adı Shape Leng Shape Area Geometry
ADANA 8.271786 1.4070835 MULTIPOLYGON (((36.31587 38…
ADIYAMAN 5.494422 0.7505609 MULTIPOLYGON (((39.25297 38…
AFYONKARAHİSAR 7.149996 1.4500639 MULTIPOLYGON (((31.14797 39…
AĞRI 6.588304 1.1631700 MULTIPOLYGON (((43.28706 40…
AKSARAY 4.432509 0.7903876 MULTIPOLYGON (((33.96446 39…
AMASYA 4.904403 0.5997255 MULTIPOLYGON (((35.24601 41…
ANKARA 11.822914 2.6956857 MULTIPOLYGON (((32.59386 40…
ANTALYA 11.935403 2.0382619 MULTIPOLYGON (((29.91377 36…
ARDAHAN 4.225177 0.5292061 MULTIPOLYGON (((42.70106 41…
ARTVİN 4.699979 0.7928665 MULTIPOLYGON (((41.96935 41…
AYDIN 6.538303 0.8255671 MULTIPOLYGON (((28.36602 38…
BALIKESİR 12.315748 1.5336854 MULTIPOLYGON (((26.63628 39…
BARTIN 2.884653 0.2515643 MULTIPOLYGON (((32.7391 41….
BATMAN 3.765845 0.4590070 MULTIPOLYGON (((41.63692 38…
BAYBURT 3.171421 0.3964768 MULTIPOLYGON (((40.13141 40…
BİLECİK 3.414509 0.4413964 MULTIPOLYGON (((30.023 40.4…
BİNGÖL 5.268994 0.8328325 MULTIPOLYGON (((40.60736 39…
BİTLİS 5.159675 0.8569274 MULTIPOLYGON (((42.9998 39….
BOLU 5.430726 0.8843812 MULTIPOLYGON (((32.26899 41…
BURDUR 5.005489 0.7303197 MULTIPOLYGON (((30.43076 37…
BURSA 6.138026 1.1422793 MULTIPOLYGON (((28.53602 40…
ÇANAKKALE 9.260139 1.0437308 MULTIPOLYGON (((26.0523 39….
ÇANKIRI 4.644764 0.8034876 MULTIPOLYGON (((33.22741 41…
ÇORUM 6.213830 1.3215895 MULTIPOLYGON (((34.55442 41…
DENİZLİ 7.035504 1.2401555 MULTIPOLYGON (((29.88782 38…
DİYARBAKIR 7.045682 1.5427158 MULTIPOLYGON (((41.15871 38…
DÜZCE 2.849445 0.2675564 MULTIPOLYGON (((31.27915 41…
EDİRNE 5.941378 0.6590750 MULTIPOLYGON (((26.93362 42…
ELAZIĞ 6.396555 0.9711793 MULTIPOLYGON (((40.23138 39…
ERZİNCAN 7.915849 1.2401317 MULTIPOLYGON (((40.09536 40…
ERZURUM 9.463435 2.6395870 MULTIPOLYGON (((42.12627 40…
ESKİŞEHIR 6.644221 1.4638394 MULTIPOLYGON (((30.76429 40…
GAZİANTEP 5.420913 0.6895780 MULTIPOLYGON (((37.70403 37…
GİRESUN 4.889698 0.7425764 MULTIPOLYGON (((37.99712 40…
GÜMÜŞHANE 4.864366 0.7068033 MULTIPOLYGON (((39.16747 40…
HAKKARİ 5.323444 0.7234147 MULTIPOLYGON (((44.07318 37…
HATAY 5.245073 0.5542336 MULTIPOLYGON (((36.22622 36…
IĞDIR 4.213092 0.3858036 MULTIPOLYGON (((43.34425 40…
ISPARTA 4.477089 0.9167380 MULTIPOLYGON (((31.08487 38…
İSTANBUL 8.478938 0.5866183 MULTIPOLYGON (((29.14379 40…
İZMİR 15.963794 1.2273672 MULTIPOLYGON (((26.88347 38…
KAHRAMANMARAŞ 6.094586 1.4871970 MULTIPOLYGON (((37.14676 38…
KARABÜK 3.511502 0.4444880 MULTIPOLYGON (((33.00096 41…
KARAMAN 6.072094 0.8795315 MULTIPOLYGON (((33.85023 37…
KARS 5.561932 1.0823148 MULTIPOLYGON (((43.45746 41…
KASTAMONU 6.900303 1.4085062 MULTIPOLYGON (((33.34503 42…
KAYSERİ 7.575294 1.7551544 MULTIPOLYGON (((35.96528 39…
KİLİS 2.510894 0.1424337 MULTIPOLYGON (((36.98933 37…
KIRIKKALE 3.493220 0.5043262 MULTIPOLYGON (((33.71753 40…
KIRKLARELİ 4.987208 0.6992569 MULTIPOLYGON (((27.24969 42…
KIRŞEHİR 4.075713 0.6876437 MULTIPOLYGON (((34.1286 39….
KOCAELİ 5.251204 0.3631846 MULTIPOLYGON (((30.27095 41…
KONYA 12.843460 4.1912128 MULTIPOLYGON (((33.00767 39…
KÜTAHYA 5.639428 1.2148052 MULTIPOLYGON (((29.68658 39…
MALATYA 7.209746 1.2663123 MULTIPOLYGON (((38.55418 39…
MANİSA 6.927719 1.3824484 MULTIPOLYGON (((27.43909 39…
MARDİN 6.103226 0.8929493 MULTIPOLYGON (((40.86731 37…
MERSİN 8.927775 1.6119979 MULTIPOLYGON (((34.61404 36…
MUĞLA 19.055281 1.2828389 MULTIPOLYGON (((29.02692 36…
MUŞ 5.282574 0.9147044 MULTIPOLYGON (((42.44476 39…
NEVŞEHİR 3.948060 0.5687378 MULTIPOLYGON (((34.8513 39….
NİĞDE 4.332359 0.7411794 MULTIPOLYGON (((34.60154 38…
ORDU 4.850937 0.6328541 MULTIPOLYGON (((37.17516 41…
OSMANİYE 3.219062 0.3373474 MULTIPOLYGON (((36.20403 37…
RİZE 3.294541 0.4107964 MULTIPOLYGON (((41.35023 41…
SAKARYA 4.043720 0.5151588 MULTIPOLYGON (((30.37474 41…
SAMSUN 7.110423 1.0472967 MULTIPOLYGON (((35.95505 41…
ŞANLIURFA 7.248394 1.9545154 MULTIPOLYGON (((39.14613 37…
SİİRT 4.019729 0.5857033 MULTIPOLYGON (((41.85338 38…
SİNOP 5.397845 0.6174678 MULTIPOLYGON (((34.94445 42…
ŞIRNAK 5.901009 0.7212010 MULTIPOLYGON (((42.98016 37…
SİVAS 10.820126 2.9517818 MULTIPOLYGON (((38.07052 40…
TEKİRDAĞ 4.899891 0.6636037 MULTIPOLYGON (((28.09059 41…
TOKAT 6.279491 1.0647630 MULTIPOLYGON (((36.64957 40…
TRABZON 4.277406 0.4954579 MULTIPOLYGON (((39.43447 41…
TUNCELİ 5.408472 0.7906146 MULTIPOLYGON (((39.79968 39…
UŞAK 3.864988 0.5742211 MULTIPOLYGON (((29.74957 38…
VAN 8.362708 2.1597433 MULTIPOLYGON (((43.86293 39…
YALOVA 2.051652 0.0870164 MULTIPOLYGON (((29.5329 40….
YOZGAT 6.386410 1.4367432 MULTIPOLYGON (((35.38648 40…
ZONGULDAK 3.270366 0.3604839 MULTIPOLYGON (((32.12947 41…

Here is the second sf data named tur_pntcntr_adm1_sf.

tur_pntcntr_adm1_sf %>%
  select("İl Adı"=adm1_tr, "Latitude"=latitude, "Longitude"=longitude  ,Geometry="geometry") %>%
     kbl(caption = "tur_pntcntr_adm1_sf", align="cccc")%>%
        kable_styling(bootstrap_options = c("striped",
                                            "hover",
                                            "condensed",
                                            "responsive"),
                      font_size = 12) %>%
          scroll_box(width = "500px", height = "250px")
tur_pntcntr_adm1_sf
İl Adı Latitude Longitude Geometry
ADANA 36.98451 35.33368 POINT (35.33368 36.98451)
ADIYAMAN 37.76601 38.27676 POINT (38.27676 37.76601)
AFYONKARAHİSAR 38.75812 30.53685 POINT (30.53685 38.75812)
AĞRI 39.71944 43.05036 POINT (43.05036 39.71944)
AKSARAY 38.37134 34.02710 POINT (34.0271 38.37134)
AMASYA 40.65100 35.83337 POINT (35.83338 40.651)
ANKARA 39.92979 32.85292 POINT (32.85292 39.92979)
ANTALYA 36.88909 30.70401 POINT (30.70401 36.88909)
ARDAHAN 41.11366 42.70139 POINT (42.70139 41.11366)
ARTVİN 41.18112 41.82085 POINT (41.82085 41.18112)
AYDIN 37.84879 27.84343 POINT (27.84343 37.84879)
BALIKESİR 39.63782 27.87399 POINT (27.87399 39.63782)
BARTIN 41.63366 32.33739 POINT (32.33739 41.63366)
BATMAN 37.87676 41.11442 POINT (41.11442 37.87676)
BAYBURT 40.25810 40.22509 POINT (40.22509 40.2581)
BİLECİK 40.14392 29.98063 POINT (29.98063 40.14392)
BİNGÖL 38.88471 40.49685 POINT (40.49685 38.88471)
BİTLİS 38.40435 42.10764 POINT (42.10764 38.40435)
BOLU 40.73318 31.60296 POINT (31.60296 40.73318)
BURDUR 37.72042 30.28324 POINT (30.28324 37.72042)
BURSA 40.19650 29.05892 POINT (29.05892 40.1965)
ÇANAKKALE 40.14650 26.40629 POINT (26.40629 40.1465)
ÇANKIRI 40.59966 33.61637 POINT (33.61637 40.59966)
ÇORUM 40.55039 34.95497 POINT (34.95497 40.55039)
DENİZLİ 37.78175 29.08604 POINT (29.08604 37.78175)
DİYARBAKIR 37.91363 40.21721 POINT (40.21721 37.91363)
DÜZCE 40.83948 31.16386 POINT (31.16386 40.83948)
EDİRNE 41.67642 26.55241 POINT (26.55241 41.67642)
ELAZIĞ 38.67313 39.22912 POINT (39.22912 38.67313)
ERZİNCAN 39.74847 39.47915 POINT (39.47915 39.74847)
ERZURUM 39.90616 41.27401 POINT (41.27401 39.90616)
ESKİŞEHİR 39.76763 30.51334 POINT (30.51334 39.76763)
GAZİANTEP 37.06145 37.36917 POINT (37.36917 37.06145)
GİRESUN 40.91948 38.38602 POINT (38.38602 40.91948)
GÜMÜŞHANE 40.45843 39.47826 POINT (39.47826 40.45843)
HAKKARİ 37.57565 43.73767 POINT (43.73767 37.57565)
HATAY 36.19888 36.15889 POINT (36.15889 36.19888)
IĞDIR 39.92294 44.04550 POINT (44.0455 39.92294)
ISPARTA 37.75921 30.54808 POINT (30.54808 37.75921)
İSTANBUL 41.01227 28.97590 POINT (28.9759 41.01227)
İZMİR 38.43414 27.17187 POINT (27.17187 38.43414)
KAHRAMANMARAŞ 37.57726 36.92770 POINT (36.9277 37.57726)
KARABÜK 41.19592 32.60845 POINT (32.60845 41.19592)
KARAMAN 37.18275 33.21599 POINT (33.21599 37.18275)
KARS 40.60289 43.09508 POINT (43.09508 40.60289)
KASTAMONU 41.37577 33.77875 POINT (33.77875 41.37577)
KAYSERİ 38.72229 35.48863 POINT (35.48863 38.72229)
KİLİS 36.71558 37.11333 POINT (37.11333 36.71558)
KIRIKKALE 39.83996 33.50399 POINT (33.50399 39.83996)
KIRKLARELİ 41.73592 27.21886 POINT (27.21886 41.73592)
KIRŞEHİR 39.14643 34.15977 POINT (34.15977 39.14643)
KOCAELİ 40.76475 29.92162 POINT (29.92162 40.76475)
KONYA 37.87231 32.49598 POINT (32.49598 37.87231)
KÜTAHYA 39.41959 29.98437 POINT (29.98437 39.41959)
MALATYA 38.34150 38.31345 POINT (38.31345 38.3415)
MANİSA 38.62227 27.43366 POINT (27.43366 38.62227)
MARDİN 37.31229 40.73779 POINT (40.73779 37.31229)
MERSİN 36.80125 34.63378 POINT (34.63378 36.80125)
MUĞLA 37.21597 28.36262 POINT (28.36262 37.21597)
MUŞ 38.73220 41.48898 POINT (41.48898 38.7322)
NEVŞEHİR 38.62958 34.72326 POINT (34.72326 38.62958)
NİĞDE 37.97004 34.67665 POINT (34.67665 37.97004)
ORDU 40.98443 37.87781 POINT (37.87781 40.98443)
OSMANİYE 37.07503 36.24845 POINT (36.24845 37.07503)
RİZE 41.02385 40.52051 POINT (40.52051 41.02385)
SAKARYA 40.78056 30.39999 POINT (30.39999 40.78056)
SAMSUN 41.28983 36.33806 POINT (36.33806 41.28983)
SİİRT 37.92536 41.94278 POINT (41.94278 37.92536)
SİNOP 42.02687 35.15196 POINT (35.15196 42.02687)
SİVAS 39.75029 37.01580 POINT (37.0158 39.75029)
ŞANLIURFA 37.15359 38.78604 POINT (38.78604 37.15359)
ŞIRNAK 37.52226 42.45676 POINT (42.45676 37.52226)
TEKİRDAĞ 40.97556 27.50939 POINT (27.50939 40.97556)
TOKAT 40.31415 36.55247 POINT (36.55247 40.31415)
TRABZON 41.00313 39.70217 POINT (39.70217 41.00313)
TUNCELİ 39.10721 39.54622 POINT (39.54622 39.10721)
UŞAK 38.67029 29.40225 POINT (29.40225 38.67029)
VAN 38.50164 43.39541 POINT (43.39541 38.50164)
YALOVA 40.65554 29.27108 POINT (29.27108 40.65554)
YOZGAT 39.82322 34.80762 POINT (34.80762 39.82322)
ZONGULDAK 41.45203 31.78192 POINT (31.78192 41.45203)

The web page with the specified url has been captured for Web Scraping process.

url = "https://covid19.saglik.gov.tr/"

html = read_html(url)

Data were obtained from the table on the web page with the help of various functions.

table_data = html %>% 
              html_elements("table") %>%
                .[[1]] %>%
                  html_table()

Here is the table_data showing the weekly number of cases per 100 thousand by provinces.

table_data %>%
  kbl(caption="İllere Göre Haftalık Vaka Sayısı (100 binde)", align = "cc") %>%
    kable_styling(bootstrap_options = c("striped",
                                        "hover",
                                        "condensed",
                                        "responsive"),
                  font_size = 15) %>%
      scroll_box(width = "500px", height = "250px")
İllere Göre Haftalık Vaka Sayısı (100 binde)
İl Adı Sayı
Adana 263,87
Adıyaman 29,25
Afyon 63,10
Ağrı 7,47
Aksaray 51,30
Amasya 202,69
Ankara 144,10
Antalya 66,55
Ardahan 40,56
Artvin 241,89
Aydın 59,07
Balıkesir 257,92
Bartın 135,19
Batman 12,74
Bayburt 13,43
Bilecik 331,94
Bingöl 20,23
Bitlis 8,55
Bolu 252,54
Burdur 204,80
Bursa 180,15
Çanakkale 456,84
Çankırı 104,97
Çorum 198,82
Denizli 223,65
Diyarbakır 21,36
Düzce 173,88
Edirne 306,80
Elazığ 39,97
Erzincan 100,24
Erzurum 23,47
Eskişehir 358,79
Gaziantep 26,13
Giresun 278,57
Gümüşhane 127,03
Hakkari 2,50
Hatay 223,40
Iğdır 45,70
Isparta 205,99
İstanbul 244,15
İzmir 67,97
Kahramanmaraş 61,55
Karabük 167,07
Karaman 63,55
Kars 19,65
Kastamonu 181,47
Kayseri 53,04
Kırıkkale 78,94
Kırklareli 445,63
Kırşehir 117,68
Kilis 48,32
Kocaeli 256,60
Konya 59,02
Kütahya 143,23
Malatya 16,13
Manisa 158,35
Mardin 10,18
Mersin 276,07
Muğla 58,16
Muş 6,08
Nevşehir 112,80
Niğde 86,72
Ordu 386,26
Osmaniye 294,04
Rize 254,10
Sakarya 185,39
Samsun 249,91
Siirt 18,43
Sinop 253,16
Sivas 53,78
Şanlıurfa 13,76
Şırnak 6,69
Tekirdağ 351,32
Tokat 253,40
Trabzon 326,15
Tunceli 154,60
Uşak 101,78
Van 2,44
Yalova 231,12
Yozgat 69,67
Zonguldak 190,97

A conversion operation was performed for a variable in the data named table_data.

#The variable named Sayı has been converted from character data type to numeric data type.
table_data$Sayı = as.numeric(gsub(",",".", table_data$Sayı))

A column named Category has been added to table_data.

#The column named Category, which has an ordered factor structure,
# is filled with values corresponding to the specified conditions.
table_data = table_data %>%
                      mutate(Category = case_when(0<=Sayı & Sayı<=51 ~ "1",
                                                  51<Sayı & Sayı<=150 ~ "2",
                                                  150<Sayı & Sayı<=200 ~ "3",
                                                  200<Sayı & Sayı<=250 ~ "4",
                                                  250<Sayı ~ "5")) %>%
                        mutate(Category = factor(Category,
                                                 levels=c("1",
                                                          "2",
                                                          "3",
                                                          "4",
                                                          "5"),
                                                 ordered = TRUE))

This is the final version of the table_data.

table_data %>%
  kbl(caption="İllere Göre Haftalık Vaka Sayısı (100 binde)", align = "ccc") %>%
    kable_styling(bootstrap_options = c("striped",
                                        "hover",
                                        "condensed",
                                        "responsive"),
                  font_size = 15) %>%
      scroll_box(width = "500px", height = "250px") 
İllere Göre Haftalık Vaka Sayısı (100 binde)
İl Adı Sayı Category
Adana 263.87 5
Adıyaman 29.25 1
Afyon 63.10 2
Ağrı 7.47 1
Aksaray 51.30 2
Amasya 202.69 4
Ankara 144.10 2
Antalya 66.55 2
Ardahan 40.56 1
Artvin 241.89 4
Aydın 59.07 2
Balıkesir 257.92 5
Bartın 135.19 2
Batman 12.74 1
Bayburt 13.43 1
Bilecik 331.94 5
Bingöl 20.23 1
Bitlis 8.55 1
Bolu 252.54 5
Burdur 204.80 4
Bursa 180.15 3
Çanakkale 456.84 5
Çankırı 104.97 2
Çorum 198.82 3
Denizli 223.65 4
Diyarbakır 21.36 1
Düzce 173.88 3
Edirne 306.80 5
Elazığ 39.97 1
Erzincan 100.24 2
Erzurum 23.47 1
Eskişehir 358.79 5
Gaziantep 26.13 1
Giresun 278.57 5
Gümüşhane 127.03 2
Hakkari 2.50 1
Hatay 223.40 4
Iğdır 45.70 1
Isparta 205.99 4
İstanbul 244.15 4
İzmir 67.97 2
Kahramanmaraş 61.55 2
Karabük 167.07 3
Karaman 63.55 2
Kars 19.65 1
Kastamonu 181.47 3
Kayseri 53.04 2
Kırıkkale 78.94 2
Kırklareli 445.63 5
Kırşehir 117.68 2
Kilis 48.32 1
Kocaeli 256.60 5
Konya 59.02 2
Kütahya 143.23 2
Malatya 16.13 1
Manisa 158.35 3
Mardin 10.18 1
Mersin 276.07 5
Muğla 58.16 2
Muş 6.08 1
Nevşehir 112.80 2
Niğde 86.72 2
Ordu 386.26 5
Osmaniye 294.04 5
Rize 254.10 5
Sakarya 185.39 3
Samsun 249.91 4
Siirt 18.43 1
Sinop 253.16 5
Sivas 53.78 2
Şanlıurfa 13.76 1
Şırnak 6.69 1
Tekirdağ 351.32 5
Tokat 253.40 5
Trabzon 326.15 5
Tunceli 154.60 3
Uşak 101.78 2
Van 2.44 1
Yalova 231.12 4
Yozgat 69.67 2
Zonguldak 190.97 3

A sub-data including the names of the provinces in Turkey and the geometry features of these provinces was created.

#The variable containing the names of the provinces has been renamed to "İl Adı".
geometry_of_provinces = tur_polbnda_adm1_sf %>%
                          select(adm1_tr) %>%
                            rename("İl Adı" = "adm1_tr")
geometry_of_provinces
İl Adı geometry
ADANA MULTIPOLYGON (((36.31587 38…
ADIYAMAN MULTIPOLYGON (((39.25297 38…
AFYONKARAHİSAR MULTIPOLYGON (((31.14797 39…
AĞRI MULTIPOLYGON (((43.28706 40…
AKSARAY MULTIPOLYGON (((33.96446 39…
AMASYA MULTIPOLYGON (((35.24601 41…

Necessary changes have been made so that the names of the provinces in the table_data and geometry_of_provinces are in the same order.

table_data[c(48,49,50,51,68,69,70,71,72),] = table_data[c(51,48,49,50,71,68,69,72,70),]

The spelling of city names in table_data and geometry_of_provinces has been made the same.

geometry_of_provinces[,"İl Adı"] = table_data[,"İl Adı"]

By merging the table_data and geometry_of_provinces, the data to be used in the visualization of the map is obtained.

map_data = merge(geometry_of_provinces,table_data)
map_data %>%
  kbl(caption="map_data",align="cccc") %>%
    kable_styling(bootstrap_options = c("striped",
                                         "hover",
                                         "condensed",
                                         "responsive"),
                  font_size = 12) %>%
    scroll_box(width = "500px", height = "250px")
map_data
İl Adı Sayı Category geometry
Adana 263.87 5 MULTIPOLYGON (((36.31587 38…
Adıyaman 29.25 1 MULTIPOLYGON (((39.25297 38…
Afyon 63.10 2 MULTIPOLYGON (((31.14797 39…
Ağrı 7.47 1 MULTIPOLYGON (((43.28706 40…
Aksaray 51.30 2 MULTIPOLYGON (((33.96446 39…
Amasya 202.69 4 MULTIPOLYGON (((35.24601 41…
Ankara 144.10 2 MULTIPOLYGON (((32.59386 40…
Antalya 66.55 2 MULTIPOLYGON (((29.91377 36…
Ardahan 40.56 1 MULTIPOLYGON (((42.70106 41…
Artvin 241.89 4 MULTIPOLYGON (((41.96935 41…
Aydın 59.07 2 MULTIPOLYGON (((28.36602 38…
Balıkesir 257.92 5 MULTIPOLYGON (((26.63628 39…
Bartın 135.19 2 MULTIPOLYGON (((32.7391 41….
Batman 12.74 1 MULTIPOLYGON (((41.63692 38…
Bayburt 13.43 1 MULTIPOLYGON (((40.13141 40…
Bilecik 331.94 5 MULTIPOLYGON (((30.023 40.4…
Bingöl 20.23 1 MULTIPOLYGON (((40.60736 39…
Bitlis 8.55 1 MULTIPOLYGON (((42.9998 39….
Bolu 252.54 5 MULTIPOLYGON (((32.26899 41…
Burdur 204.80 4 MULTIPOLYGON (((30.43076 37…
Bursa 180.15 3 MULTIPOLYGON (((28.53602 40…
Çanakkale 456.84 5 MULTIPOLYGON (((26.0523 39….
Çankırı 104.97 2 MULTIPOLYGON (((33.22741 41…
Çorum 198.82 3 MULTIPOLYGON (((34.55442 41…
Denizli 223.65 4 MULTIPOLYGON (((29.88782 38…
Diyarbakır 21.36 1 MULTIPOLYGON (((41.15871 38…
Düzce 173.88 3 MULTIPOLYGON (((31.27915 41…
Edirne 306.80 5 MULTIPOLYGON (((26.93362 42…
Elazığ 39.97 1 MULTIPOLYGON (((40.23138 39…
Erzincan 100.24 2 MULTIPOLYGON (((40.09536 40…
Erzurum 23.47 1 MULTIPOLYGON (((42.12627 40…
Eskişehir 358.79 5 MULTIPOLYGON (((30.76429 40…
Gaziantep 26.13 1 MULTIPOLYGON (((37.70403 37…
Giresun 278.57 5 MULTIPOLYGON (((37.99712 40…
Gümüşhane 127.03 2 MULTIPOLYGON (((39.16747 40…
Hakkari 2.50 1 MULTIPOLYGON (((44.07318 37…
Hatay 223.40 4 MULTIPOLYGON (((36.22622 36…
Iğdır 45.70 1 MULTIPOLYGON (((43.34425 40…
Isparta 205.99 4 MULTIPOLYGON (((31.08487 38…
İstanbul 244.15 4 MULTIPOLYGON (((29.14379 40…
İzmir 67.97 2 MULTIPOLYGON (((26.88347 38…
Kahramanmaraş 61.55 2 MULTIPOLYGON (((37.14676 38…
Karabük 167.07 3 MULTIPOLYGON (((33.00096 41…
Karaman 63.55 2 MULTIPOLYGON (((33.85023 37…
Kars 19.65 1 MULTIPOLYGON (((43.45746 41…
Kastamonu 181.47 3 MULTIPOLYGON (((33.34503 42…
Kayseri 53.04 2 MULTIPOLYGON (((35.96528 39…
Kilis 48.32 1 MULTIPOLYGON (((36.98933 37…
Kırıkkale 78.94 2 MULTIPOLYGON (((33.71753 40…
Kırklareli 445.63 5 MULTIPOLYGON (((27.24969 42…
Kırşehir 117.68 2 MULTIPOLYGON (((34.1286 39….
Kocaeli 256.60 5 MULTIPOLYGON (((30.27095 41…
Konya 59.02 2 MULTIPOLYGON (((33.00767 39…
Kütahya 143.23 2 MULTIPOLYGON (((29.68658 39…
Malatya 16.13 1 MULTIPOLYGON (((38.55418 39…
Manisa 158.35 3 MULTIPOLYGON (((27.43909 39…
Mardin 10.18 1 MULTIPOLYGON (((40.86731 37…
Mersin 276.07 5 MULTIPOLYGON (((34.61404 36…
Muğla 58.16 2 MULTIPOLYGON (((29.02692 36…
Muş 6.08 1 MULTIPOLYGON (((42.44476 39…
Nevşehir 112.80 2 MULTIPOLYGON (((34.8513 39….
Niğde 86.72 2 MULTIPOLYGON (((34.60154 38…
Ordu 386.26 5 MULTIPOLYGON (((37.17516 41…
Osmaniye 294.04 5 MULTIPOLYGON (((36.20403 37…
Rize 254.10 5 MULTIPOLYGON (((41.35023 41…
Sakarya 185.39 3 MULTIPOLYGON (((30.37474 41…
Samsun 249.91 4 MULTIPOLYGON (((35.95505 41…
Siirt 18.43 1 MULTIPOLYGON (((41.85338 38…
Sinop 253.16 5 MULTIPOLYGON (((34.94445 42…
Sivas 53.78 2 MULTIPOLYGON (((38.07052 40…
Şanlıurfa 13.76 1 MULTIPOLYGON (((39.14613 37…
Şırnak 6.69 1 MULTIPOLYGON (((42.98016 37…
Tekirdağ 351.32 5 MULTIPOLYGON (((28.09059 41…
Tokat 253.40 5 MULTIPOLYGON (((36.64957 40…
Trabzon 326.15 5 MULTIPOLYGON (((39.43447 41…
Tunceli 154.60 3 MULTIPOLYGON (((39.79968 39…
Uşak 101.78 2 MULTIPOLYGON (((29.74957 38…
Van 2.44 1 MULTIPOLYGON (((43.86293 39…
Yalova 231.12 4 MULTIPOLYGON (((29.5329 40….
Yozgat 69.67 2 MULTIPOLYGON (((35.38648 40…
Zonguldak 190.97 3 MULTIPOLYGON (((32.12947 41…

Labels that will appear when hovering over provinces on the map have been created.

labels <-  sprintf("<strong>%s</strong><br/>
                    <strong> %s</strong>", map_data$"İl Adı", map_data$Sayı) %>%
                    lapply(htmltools::HTML)

A sequential color palette was created with colors corresponding to the specified levels.

#Colors are taken from the map requested from us for each level specified with the help of the colorzilla plugin in Chrome.
pal_col = colorFactor(palette = c("#DAD9D7",
                                  "#D1D0CE",
                                  "#9C9C9C",
                                  "#858585",
                                  "#7A7878"), 
                      domain = map_data$Category,
                      levels = c("1",
                                 "2",
                                 "3",
                                 "4",
                                 "5"),
                      ordered = TRUE)

The necessary actions have been taken to add a title to the map.

tag.map.title <- tags$style(HTML("
  .leaflet-control.map-title { 
    transform: translate(-50%,20%);
    position: fixed !important;
    left: 50%;
    text-align: center;
    padding-left: 70px; 
    padding-right: 70px; 
    background: #199F9B;
    color:white;
    font-weight: bold;
    font-size: 17px;
  }
"))


title <- tags$div(
  tag.map.title, HTML("İllere Göre Haftalık Vaka Sayısı (100 binde) </br>
                      11-17 Aralık 2021")
)  

A map was created using the data named map_data.

map = map_data %>%
         leaflet() %>%
          addPolygons(color = "white",
                      weight = 1,
                      fillColor = ~pal_col(Category),
                      fillOpacity = 1,
                      smoothFactor = 1,
                      label = labels,
                      labelOptions = labelOptions(style = list("color" = "white", #for popup label
                                                               "background-color" = "#1B888C",
                                                               "border-color" = "#1B888C",
                                                               "padding" = "20px"),
                                                  textsize = "15px",
                                                  direction = "auto"),
                      highlight = highlightOptions(weight = 1,
                                                   fillColor = "#0E5C59",
                                                   bringToFront = TRUE)) %>% 
            addLabelOnlyMarkers(lng = tur_pntcntr_adm1_sf$longitude,
                                lat = tur_pntcntr_adm1_sf$latitude,
                                label = ~Sayı,
                                labelOptions = labelOptions(noHide = T, 
                                                            direction = "center",
                                                            textsize = "9px",
                                                            style = list("color" = "white",
                                                                         "background-color" = "#0E5C59",
                                                                         "border-color" = "#0E5C59",
                                                                         "border-radius" = "35%",
                                                                         "padding" = "0px"))) %>%
                addControl(title, position = "topleft", className="map-title") 

map

map is saved in the file named map.html.

saveWidget(map, file="map.html",  selfcontained = FALSE)

`